import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { Park } from '../../providers/park-data/park';
import { ParkDataProvider } from '../../providers/park-data/park-data';


/**
 * Generated class for the ParkListPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@Component({
  selector: 'page-park-list',
  templateUrl: 'park-list.html',
})
export class ParkListPage {


  parks: Park[] = [];

  private num: number = 10; //每页显示记录数
  private curPage: number = 1; //当前页数

  constructor(
    public navCtrl: NavController, 
    public navParams: NavParams,
    public parkDataProvider: ParkDataProvider) {
  }

  ionViewDidLoad() {  
     this.getParks (this.num, this.curPage);
  }

  getParks(num: number, page: number): void {
    this.parkDataProvider.getParks(num, page).subscribe(parks=>{
      this.parks = parks;
    });
  }

}
